package com.sec.etech.sys.vo;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import lombok.Data;

import java.util.Date;

@Data
public class AsyncData {
    /**
     * 有效时间秒 10分钟
     */
    private int time = 600;

    /**
     * 过期时间
     */
    private String expiretime;

    /**
     * 请求状态
     * 0:处理中 1：处理完成 2：处理异常
     */
    private int status;
    /**
     * 处理完后的数据
     */
    private Object data;
    /**
     * 信息
     */
    private String msg;

    public AsyncData() {
        this.status = 0;
        this.expiretime = DateUtil.formatDateTime(DateUtil.offset(new Date(), DateField.SECOND, this.getTime()));
    }

    public void complete(Object data) {
        this.status = 1;
        this.data = data;
    }

    public void error(String msg) {
        this.status = 2;
        this.msg = msg;
    }
}
